#pragma once

#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unistd.h>
#include <functional>

// typedef std::function<void()> func;
using func = std::function<void()>;

std::vector<func> callback;
std::unordered_map<int, std::string> desc;

void readMySQL()
{
    std::cout << "process[" << getpid() << ']' << "执行访问数据库的任务" << std::endl;
}
void execuleUrl()
{
    std::cout << "process[" << getpid() << ']' << "执行访问Url的解析" << std::endl;
}
void cal()
{
    std::cout << "process[" << getpid() << ']' << "执行访问加密的任务" << std::endl;
}
void save()
{
    std::cout << "process[" << getpid() << ']' << "执行数据持久化的任务" << std::endl;
}

void load()
{
    desc.insert(callback.size(), "readMySQL");
    callback.push_back(readMySQL);

    desc.insert(callback.size(), "execuleUrl");
    callback.push_back(execuleUrl);

    desc.insert(callback.size(), "cal");
    callback.push_back(cal);

    desc.insert(callback.size(), "save");
    callback.push_back(save);
}

void showHead()
{
    for (auto &i : desc)
    {
        std::cout << i.first << "\t" << i.second << std::endl;
    }
}